package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.estatewar.palace.*;
import com.yanqu.road.pb.estatewar.EstateWarProto;

import java.util.List;

public class PalacePb {

    public static EstateWarProto.PalaceBattleRecordListMsg.Builder parsePalaceBattleRecordListMsg(List<PalaceBattleRecord> dataList){
        EstateWarProto.PalaceBattleRecordListMsg.Builder listMsg = EstateWarProto.PalaceBattleRecordListMsg.newBuilder();
        if(null != dataList){
            for(PalaceBattleRecord data : dataList){
                EstateWarProto.PalaceBattleRecordTempMsg.Builder msg = parsePalaceBattleRecordTempMsg(data);
                if(null != msg){
                    listMsg.addDataList(msg);
                }
            }
        }
        return listMsg;
    }

    public static EstateWarProto.PalaceBattleRecordTempMsg.Builder parsePalaceBattleRecordTempMsg(PalaceBattleRecord data){
        if(null == data){
            return null;
        }
        EstateWarProto.PalaceBattleRecordTempMsg.Builder msg = EstateWarProto.PalaceBattleRecordTempMsg.newBuilder();
        msg.setRecordUid(data.getRecordUid());
        msg.setIsWin(data.isWin());
        msg.setRecordTime(data.getRecordTime());
        msg.setEnemyUserId(data.getEnemyUserId());
        msg.setEnemyBaseData(PlayerBasePb.parsePlayerBaseTempMsg(data.getEnemyUserInfo()));
        msg.setOldPos(data.getOldPos());
        msg.setNowPos(data.getNowPos());
        return msg;
    }

    public static EstateWarProto.PalaceBattleNoticeListMsg.Builder parsePalaceBattleNoticeListMsg(List<PalaceBattleNotice> dataList){
        EstateWarProto.PalaceBattleNoticeListMsg.Builder listMsg = EstateWarProto.PalaceBattleNoticeListMsg.newBuilder();
        if(null != dataList){
            for(PalaceBattleNotice data : dataList){
                EstateWarProto.PalaceBattleNoticeTempMsg.Builder msg = parsePalaceBattleNoticeTempMsg(data);
                if(null != msg){
                    listMsg.addDataList(msg);
                }
            }
        }
        return listMsg;
    }

    public static EstateWarProto.PalaceBattleNoticeTempMsg.Builder parsePalaceBattleNoticeTempMsg(PalaceBattleNotice data){
        if(null == data){
            return null;
        }
        EstateWarProto.PalaceBattleNoticeTempMsg.Builder msg = EstateWarProto.PalaceBattleNoticeTempMsg.newBuilder();
        msg.setNoticeUid(data.getNoticeUid());
        msg.setIsWin(data.isWin());
        msg.setNoticeTime(data.getNoticeTime());
        msg.setUserId(data.getUserId());
        msg.setUserBaseData(PlayerBasePb.parsePlayerBaseTempMsg(data.getUserInfo()));
        msg.setEnemyUserId(data.getEnemyUserId());
        msg.setEnemyBaseData(PlayerBasePb.parsePlayerBaseTempMsg(data.getEnemyUserInfo()));
        msg.setPos(data.getPos());
        return msg;
    }

    public static EstateWarProto.PalaceUserDataMsg.Builder parsePalaceUserDataMsg(UserPalaceData data){
        if(null == data){
            return null;
        }
        EstateWarProto.PalaceUserDataMsg.Builder msg = EstateWarProto.PalaceUserDataMsg.newBuilder();
        msg.setPos(data.getPos());
        msg.setWorshipTime(data.getWorshipTime());
        msg.setOnlyUnionMemberJoin(data.isOnlyUnionMemberJoin());
        msg.setAideUnder(data.getUnderAide());
        return msg;
    }
}
